<template>
  <div class="edu-page-warp">
    <base-info :student-id="studentId" :self="self"></base-info>
    <apply-check v-if="flagCheck" :data="abnormal"></apply-check>
    <apply-items v-else></apply-items>
    {{!self || flagCheck}}
    <approve-list v-if="flagExpore"></approve-list>
  </div>
</template>
<script>
import baseInfo from './StudentBaseInfo'
import applyItems from './ApplyAbnormalItems'
import approveList from './ApproveList'
import applyCheck from './ApplyAbnormalItemsCheck.vue'
import {getAbnormalDetailById} from 'common/src/api/abnormal' 
export default {
  components: {baseInfo, applyItems, approveList, applyCheck},
  mounted() {
    let {studentId, abnormalId, flagCheck} = this.$route.params
    this.self = !!studentId
    if (abnormalId) {
      this.getAbnormalDetailById(abnormalId)
    }
    
    this.flagCheck = !!flagCheck
    this.flagExpore = !!abnormalId
    // 如果参数中有学生id，表示学生自己申请异动
    // 如果参数中没有学生id,表示代申请异动
    // 如果参数中有abnormalId并且没有flagCheck，表示查看详情
    // 如果参数中有abnormalId和flagCheck,表示审核异动
   
  },
  methods: {
    getAbnormalDetailById(abnormalId) {
      getAbnormalDetailById({abnormalId}).then(response => {
          let {code, data } = response
          if (code === 200) {
            this.studentId = data.studentId
            this.abnormal = data
          }
      })
    }
  }
}
</script>
<style>
</style>
